package com.czl.module_storehouse.adapter;

import android.annotation.SuppressLint;
import android.view.View;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder;
import com.czl.base.data.bean.tengyun.SortBean;
import com.czl.module_storehouse.databinding.ItemReceiveDetailsBinding;

/**
 * @author xubin
 */
public class ReceiveDetailsAdapter extends BaseQuickAdapter<SortBean, BaseDataBindingHolder<ItemReceiveDetailsBinding>> {

    private String mNumTitle;
    private boolean isShowAmount = true;

    public ReceiveDetailsAdapter(int layoutResId, String numTitle) {
        super(layoutResId);
        this.mNumTitle = numTitle;
    }

    public void setShowAmount(boolean showAmount) {
        isShowAmount = showAmount;
    }

    public String getNumTitle() {
        return mNumTitle;
    }

    public void setNumTitle(String numTitle) {
        mNumTitle = numTitle;
    }

    @SuppressLint("SetTextI18n")
    @Override
    protected void convert(@NonNull BaseDataBindingHolder<ItemReceiveDetailsBinding> bindingHolder, SortBean item) {
        ItemReceiveDetailsBinding dataBinding = bindingHolder.getDataBinding();
        if (dataBinding == null) {
            return;
        }
        dataBinding.tvTitle.setText(item.getSortName());
        dataBinding.tvAmount.setText("数量：" + (item.getApplyNum() == null ? 0 : item.getApplyNum()));
        dataBinding.tvAmount.setVisibility(isShowAmount ? View.VISIBLE : View.GONE);
        dataBinding.tvModel.setText("型号：" + item.getSortModel());
        dataBinding.textReceive.setText(mNumTitle);
        dataBinding.tvNum.setText(String.valueOf(item.getLendNum() == null ? 0 : item.getLendNum()));
        dataBinding.shadowLayout.setShadowHiddenTop(bindingHolder.getLayoutPosition() != getHeaderLayoutCount());
    }
}
